<?php
//奖励明细
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['set']=$this->plugin_setting('basic');
$return['setting']=$this->plugin_setting('basic');
if($_RQ['op']=='main'){
	set_html('title','全部奖励');
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='getlist'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'mid'=>$_SESSION['uid'],
	);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=pdo_getslice('jy_inclock_task_reward',$params,array($pindex,$psize),$total,array(),'','id desc');
	foreach($return['list'] as $k=>&$item){
		if($item['task_progress']>=$item['task_demand']){
			$item['ispass']=1;
		}
		$isget=$this->get('task_reward',array('recordid'=>intval($item['id']),'mid'=>intval($item['mid']),'uniacid'=>$_SESSION['uniacid']));
		if($isget['id']){
			$item['isreward']=1;	
		}
		$task=$this->pdo_get('task_list',array('id'=>$item['taskid'],'uniacid'=>$_SESSION['uniacid']));
		$item['rewarddesc']='奖励';
		$reward=json_decode($task['reward'],true);
		$credit_types=credit_types();
		foreach($reward as $key=>$value){
				if(strpos($key,'credit') !== false && $value>0){
					$type=substr($key, -1);
					$item['rewarddesc'].='['.$value.$credit_types[$type].'] ';
				}
		}
	}
	exi($return);
}
